﻿Ext.onReady(function () {
    Ext.apply(Kwan, {
        def: Role
    });
});
Ext.apply(Kwan, {
    ChangePermit: function (d) {
        //创建，读取，更新，删除，审核
        //00000 表示没有任何权限，共5位
        var permit = [];
        permit['00000'] = '禁止访问';
        permit['01000'] = '只读';
        permit['01100'] = '读写';
        permit['01101'] = '读写审核';
        permit['1111'] = '全部权限';
        return (permit[d]);
    },
//    SetModule: function (roleModuleRecord, roleRecord) {
//        var msg = '',
//            selNodes = ModuleTree.getChecked();
//        Ext.each(selNodes, function (node) {
//            if (msg.length > 0) { msg += ","; }
//            msg += node.id;
//        });
//        Role.SetModule(roleRecord, roleModuleRecord, msg);
//    },
    RoleGPClick: function (id) {
        Role.GetModule(id, {
            success: function (result) {
                ModuleTree.getNodeById("root").reload(function () { });
                var data = eval("(" + result + ")");
                ModuleTree.getNodeById("root").loadNodes(data);
            }
        });
    },
    nodeLoad: function (node) {
        Role.NodeLoad(node.id, {
            success: function (result) {
                ModuleTree.getNodeById("root").reload(function () { });
                var data = eval("(" + result + ")");
                node.loadNodes(data);
                //Kwan.Debug(node);
            },
            failure: function (errorMsg) {
                Ext.Msg.alert('Failure', errorMsg);
            }
        });
    },
    LoadPermit: function (node) {
        Role.LoadPermit(node, {
            success: function (result) {
                //alert(Kwan.objToString(result));
                RoleModuleGP.getSelectionModel().selectRows(result, true);
            },
            failure: function (errorMsg) {
                Ext.Msg.alert('Failure', errorMsg);
            }
        });
    },
    ChangePermit: function (rowIndex, val, seleced) {
        if (seleced) {

        }
    }
});